<div class="wrap">
	<h2>
		<?php echo $Title;?>
	</h2>
	<?php if(isset($_POST) && !empty($_POST)):?>
		<div class="updated" id="message">
			<p><strong><?php echo $Title;?> updated.</strong></p>
		</div>
	<?php endif;?>
	<form method="post" id="formData">
		<table class="form-table">
			<tbody>
				<tr>
					<th>
						<label for="user_login">
							Username
						</label>
					</th>
					<td>
						<input type="text" class="regular-text" disabled="disabled" value="<?php echo $this->session->userdata('adminData')['username'];?>" id="user_login" name="user_login">
						<span class="description">
							Usernames cannot be changed.
						</span>
					</td>
				</tr>
				<tr>
					<th>
						<label for="email">
							E-mail
							<span class="description">
								(required)
							</span>							
						</label>
					</th>
					<td>
						<input type="text" class="regular-text required email" value="<?php echo $dataUserInfo->email;?>" id="email" name="email">
					</td>
				</tr>
				<tr>
					<th>
						<label for="first_name">
							First Name
						</label>
					</th>
					<td>
						<input type="text" class="regular-text" value="<?php echo $dataUserInfo->first_name;?>" id="first_name" name="first_name">
					</td>
				</tr>

				<tr>
					<th>
						<label for="last_name">
							Last Name
						</label>
					</th>
					<td>
						<input type="text" class="regular-text" value="<?php echo $dataUserInfo->last_name;?>" id="last_name" name="last_name">
					</td>
				</tr>

				<tr>
					<th>
						<label for="nickname">
							Nickname
							<span class="description">
								(required)
							</span>
						</label>
					</th>
					<td>
						<input type="text" class="regular-text required" value="<?php echo $dataUserInfo->nickname;?>" id="nickname" name="nickname">
					</td>
				</tr>
				<tr>
					<th>
						<label for="telephone">
							Telephone
						</label>
					</th>
					<td>
						<input type="text" class="regular-text" value="<?php echo $dataUserInfo->telephone;?>" id="telephone" name="telephone">
					</td>
				</tr>
				<tr id="password">
					<th>
						<label for="pass1">
							New Password
						</label>
					</th>
					<td>
						<input value=" " class="hidden"><!-- #24364 workaround -->
						<input type="password" autocomplete="off" value="" size="16" class="regular-text" id="pass1" name="pass1"><br>
						<span class="description">
							If you would like to change the password type a new one. Otherwise leave this blank.
						</span>
					</td>
				</tr>
				<tr>
					<th scope="row">
						<label for="pass2">
							Repeat New Password
						</label>
					</th>
					<td>
						<input type="password" autocomplete="off" value="" size="16" class="regular-text" id="pass2" name="pass2" equalTo="#pass1"><br>
						<span class="description">
							Type your new password again.
						</span>
						<br>
						<div id="pass-strength-result" style="display: block;" class="">
							Strength indicator
						</div>
						<p class="description indicator-hint">
							Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).
						</p>
					</td>
				</tr>
			</tbody>
		</table>
		<input type="hidden" value="update" name="action">
		<p class="submit">
			<input type="submit" value="Update Profile" class="button button-primary" id="submit" name="submit">
		</p>
	</form>
</div>

<script type="text/javascript">
(function($) {
/*whatever jQuery stuff*/
	$(function(){
		$.validator.addMethod("email", function(value, element) {
			var returnVal = false;
			var corectEmail = $.validator.methods.email2.call(this, value, element);
			if(!corectEmail) return returnVal;
			$.ajax({
				type:"post",
				url: "ajax_valid_email",
				data:({
					email:value,
					username: "<?php echo $this->session->userdata('adminData')['username'];?>"
				}),
				async: false
			}).done(function(data){
				if(data == "valid"){
					returnVal = true;	
				}
			});
			if(!returnVal){
				if($(element).parent().find(".description").length){
					$(element).parent().find(".description").remove();
				}
				$('<span class="description form-invalid"> This Email already exists.</span>').insertAfter(element);			
			}
			return returnVal;
		});
			
		$("#formData").validate({
			errorPlacement: function(error, element) {
				return true;
			},		
			highlight: function( element, errorClass, validClass ) {
				$(element).closest('tr').addClass('form-invalid');
			},
			unhighlight: function( element, errorClass, validClass ) {
				$(element).closest('tr').removeClass('form-invalid').find('.form-invalid').remove();
			},				
		});
	});	
})(jQuery);
</script>